﻿namespace ClassyBlog.Infrastructure.Specs.Unit
{
    using System.Web.Routing;

    using Machine.Specifications;

    public abstract class PresenceConstraintSpec
    {
        protected static PresenceConstraint constraint;
        protected static bool matched;

        Establish context = () => constraint = new PresenceConstraint();
    }

    [Subject(typeof(PresenceConstraint))]
    public class when_value_is_present : PresenceConstraintSpec
    {
        Because of = () =>
            matched = constraint.Match(
            null,
            null,
            "foo",
            new RouteValueDictionary
                {
                    { "foo", "bar" }
                },
            RouteDirection.IncomingRequest);

        It should_match = () => matched.ShouldBeTrue();
    }

    [Subject(typeof(PresenceConstraint))]
    public class when_value_is_not_present : PresenceConstraintSpec
    {
        Because of = () =>
            matched = constraint.Match(
            null,
            null,
            "foo",
            new RouteValueDictionary(),
            RouteDirection.IncomingRequest);

        It should_not_match = () => matched.ShouldBeFalse();
    }
}